package com.simulate.demo.controller;


import com.simulate.core.annotation.Autowired;
import com.simulate.core.annotation.Controller;
import com.simulate.core.annotation.RequestMapping;
import com.simulate.core.annotation.RequestParam;
import com.simulate.demo.service.SimulateService1;
import com.simulate.demo.service.SimulateService2;

import javax.servlet.http.HttpServletResponse;

/**
 * 功能描述: <br>
 * 所属包名: com.simulate.demo.controller<br>
 * 创建人　: 白剑<br>
 * 创建时间: 2018/05/27 18:04:47<br>
 * 当前版本: 1.0<br>
 * 修改历史: <br>
 * 修改时间　　　　　修改人　　　　　版本变更　　　　　修改说明<br>
 * -----------------------------------------------------<br>
 * <br>
 */
@Controller
@RequestMapping("/demo")
public class SimulateController {

    @Autowired
    private SimulateService1 simulateService1;

    @Autowired
    private SimulateService2 simulateService2;

    @RequestMapping("/info")
    public void getInfo(@RequestParam("code") String code, HttpServletResponse response) {
        try {
            response.getWriter().println(simulateService1.getInfo(code));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/sum")
    public void getSum(@RequestParam("val1") Integer val1, @RequestParam(value = "val2") Integer val2, HttpServletResponse response) {
        try {
            response.getWriter().println(val1 + " + " + val2 + " is " + simulateService2.getSum(val1, val2));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/sys2")
    public void getSys(HttpServletResponse response) {
        try {
            response.getWriter().println("sys2");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
